﻿Ext.define('HIT.controller.MdataClient', {
    extend: 'Ext.app.Controller',
    
    models : ['MdataClient','MdataClientAddress'],
    stores : ['MdataClient','MdataClientAddress'],
    views  : ['MdataClientPanel','MdataClientAddPanel','MdataClientEditPanel','MdataClientAddressAddPanel','MdataClientAddressEditPanel'],
    onButtonClick: function(button, e, options) {
//    	var p;
//        var grid=Ext.getCmp('tab-madta-client');        
//        if (grid.trim().length == 0) {
//			return;
//		}
    	if(button.id == 'mdata-client-add'){  //基本信息添加
        	add = Share.createPanelByAlias('widget.mdataclientaddpanel');
            Share.showPanelAsWindow(add);
        }else if(button.id == 'mdata-client-edit'){  //基本信息修改	
        	var check = Share.checkFun();
			if (check){
	        	var tabpanelId = 'mdata-client-main-panel';          
	            var tab = Ext.getCmp(tabpanelId);
	            if (tab.getSelectionModel().getCount() == 0) {
	            	Share.ShowMessage("I0011","一条客户基本信息");
	                return;
	            }
	            if (tab.getSelectionModel().getCount() != 1) {
	            	Share.ShowMessage("E0039","客户基本信息");
	                return;
	            }
	            
	            var row = tab.getSelectionModel().getSelection()[0];
	            MainRow = row;
	            
				edit = Share.createPanelByAlias('widget.mdataclienteditpanel');
				Ext.getCmp('hiddenID').setValue(row.get('id'));
	            var fix = Ext.getCmp('mdata-client-main-panel').getSelectionModel().getSelection()[0];
	            Ext.getCmp('mdata-client-code-edit').setValue(fix.get('code'));
	            // 编辑页面时不能修改客户代码
	            Ext.getCmp('mdata-client-code-edit').setDisabled(true);
	        	Ext.getCmp('mdata-client-suport-edit').setValue(fix.get('client_supplier'));
	        	Ext.getCmp('mdata-client-tax-edit').setValue(fix.get('tax_code'));
	        	Ext.getCmp('mdata-client-address-edit').setValue(fix.get('address'));
	        	Ext.getCmp('mdata-client-specialbank-edit').setValue(fix.get('bank_account'));
	        	Ext.getCmp('mdata-client-bank-edit').setValue(fix.get('bank'));
	        	if(fix.get('invType') == '营业税发票'){
	                Ext.getCmp('edit-invtype').setValue('BT');
	      	    }	
	            else if(fix.get('invType') == '出口发票'){
	                Ext.getCmp('edit-invtype').setValue('E_INV');
	            }
	            else if(fix.get('invType') == '增值税普通发票'){
	                Ext.getCmp('edit-invtype').setValue('N_VAT');
	            }
	            else if(fix.get('invType') == '交通运输发票'){
	                Ext.getCmp('edit-invtype').setValue('T_INV');
	            }
	            else if(fix.get('invType') == '增值税专用发票'){
	                Ext.getCmp('edit-invtype').setValue('VAT');
	            }
	            else{
	      	        Ext.getCmp('edit-invtype').setValue('ImportType');
	      	}
	        	Ext.getCmp('mdata-client-tel-edit').setValue(fix.get('tel'));
	        	Ext.getCmp('mdata-client-ck01-edit').setValue(fix.get('ck01'));
	        	Ext.getCmp('mdata-client-ck02-edit').setValue(fix.get('ck02'));
	        	Ext.getCmp('mdata-client-ck03-edit').setValue(fix.get('ck03'));
	        	Ext.getCmp('mdata-client-ck04-edit').setValue(fix.get('ck04'));
	        	Ext.getCmp('mdata-client-ck05-edit').setValue(fix.get('ck05'));
	        	Ext.getCmp('mdata-client-ck06-edit').setValue(fix.get('ck06') == "已选中" ? true : false);
	        	Ext.getCmp('mdata-client-ck07-edit').setValue(fix.get('ck07') == "已选中" ? true : false);
	        	Ext.getCmp('mdata-client-ck08-edit').setValue(fix.get('ck08') == "已选中" ? true : false);
	        	Ext.getCmp('mdata-client-ck09-edit').setValue(fix.get('ck09') == "已选中" ? true : false);
	        	Ext.getCmp('mdata-client-ck10-edit').setValue(fix.get('ck10') == "已选中" ? true : false);           
	        	Share.showPanelAsWindow(edit);
         }else {
				Share.ShowMessage("E0026");
				return;
		 }
		}else if(button.id == 'mdata-client-delete'){  //基本信息删除	
			var tabpanelId = 'mdata-client-main-panel';          
            var tab = Ext.getCmp(tabpanelId);
  
            if (tab.getSelectionModel().getCount() == 0) {
            	Share.ShowMessage("I0011","至少一条客户基本信息");
                return;
            }
            
            var row = tab.getSelectionModel().getSelection();
            
            Ext.MessageBox.confirm(Share.T('提示'),Share.T('确定删除吗？'),function(btn){
            	if(btn == 'yes'){
            		// 获取当前引用的主数据套创建公司
            		var check = Share.checkFun();
        			if (check) {
		            		var ids = "(";
		                    for(i=0,len=row.length;i<len;i++){
		                    	ids += row[i].get("id");
		                    	if(i<len-1){ids += ",";}
		                    }
		                    ids += ")";
		           		 Share.AjaxRequest({
		                        url: ctx + "/deletemdataclient",
		                        params: {
		                        	ids:ids
		                        },
		                        showMsg: false,
		                        scope: this,
		                        callback: function (json) {
		                        		Ext.getCmp('mdata-client-main-panel').getStore().reload();
		                        		Ext.getCmp('mdata-client-detail-panel').getStore().removeAll();
		                        		Ext.getCmp('mdata-client-detail-panel').getStore().reload();
		                        		if(Ext.getCmp('mdata-client-main-panel').getStore().getCount() == 1){
		                        			Ext.getCmp('mdata-client-main-panel').getStore().removeAll();
		                        			Ext.getCmp('mdata-client-pag').movePrevious();
		                        		}
		                        		Share.ShowMessage("I0006","删除");
		                        },
		                        falseFun: function (json) { //失败后想做的个性化操作函数
		                        	 Ext.MessageBox.alert(json.msg);	
		                        }
		                    }); 
		            	}else {
		    				Share.ShowMessage("E0026");
		    				return;
		    			}
            	}
		  });
		} else if(button.id == 'mdata-address-add'){  //联系方式添加
			var tabpanelId = 'mdata-client-main-panel';          
            var tab = Ext.getCmp(tabpanelId);
            if (tab.getSelectionModel().getCount() == 0) {
            	Share.ShowMessage("I0011","一条客户基本信息");
                return;
            }
            if (tab.getSelectionModel().getCount() != 1) {
            	Share.ShowMessage("E0039","客户基本信息");
                return;
            }
			add = Share.createPanelByAlias('widget.mdataclientaddressaddpanel');
            Share.showPanelAsWindow(add);
		} else if(button.id == 'mdata-address-edit'){  //联系方式修改
			var check = Share.checkFun();
			if (check) {
				var tabpanelId = 'mdata-client-detail-panel';          
	            var tab = Ext.getCmp(tabpanelId);
	            var maintab = Ext.getCmp('mdata-client-main-panel');
	            if(maintab.getSelectionModel().getCount() == 0){
	            	Share.ShowMessage("I0011","一条客户基本信息");
	            	return;
	            }
	            if (maintab.getSelectionModel().getCount() > 1) {
	            	Share.ShowMessage("E0039","客户基本信息");
	                return;
	            }
	            if (tab.getSelectionModel().getCount() == 0) {
	            	Share.ShowMessage("I0011","一条客户联系资料");
	                return;
	            }
	            if (tab.getSelectionModel().getCount() > 1) {
	            	Share.ShowMessage("E0039","客户联系资料");
	                return;
	            }
	            
	            var row = tab.getSelectionModel().getSelection()[0];
	            
				edit = Share.createPanelByAlias('widget.mdataclientaddresseditpanel');
				Ext.getCmp('hiddenID').setValue(row.get('id'));
				var fix = Ext.getCmp('mdata-client-detail-panel').getSelectionModel().getSelection()[0];
	            Ext.getCmp('mdata-client-recvcompany-edit').setValue(fix.get('recv_company'));
	        	Ext.getCmp('mdata-client-recvman-edit').setValue(fix.get('recv_ticket'));
	        	Ext.getCmp('mdata-client-recvaddress-edit').setValue(fix.get('recv_address'));
	        	Ext.getCmp('mdata-client-recvtel-edit').setValue(fix.get('recv_tel'));
	        	Ext.getCmp('mdata-client-city-edit').setValue(fix.get('city'));
	        	Ext.getCmp('mdata-client-recvremark-edit').setValue(fix.get('remark'));
	        	Ext.getCmp('mdata-client-email-edit').setValue(fix.get('recv_email'));
	        	Ext.getCmp('mdata-client-phone-number-edit').setValue(fix.get('recv_phone'));
	        	Ext.getCmp('mdata-client-recvck01-edit').setValue(fix.get('ck01'));
	        	Ext.getCmp('mdata-client-recvck02-edit').setValue(fix.get('ck02'));
	        	Ext.getCmp('mdata-client-recvck03-edit').setValue(fix.get('ck03'));
	        	Ext.getCmp('mdata-client-recvck04-edit').setValue(fix.get('ck04'));
	        	Ext.getCmp('mdata-client-recvck05-edit').setValue(fix.get('ck05'));
	            Share.showPanelAsWindow(edit);
			}else {
				Share.ShowMessage("E0026");
				return;
			}
		} else if(button.id == 'mdata-address-delete'){  //联系方式删除
			var tabpanelId = 'mdata-client-detail-panel';          
            var tab = Ext.getCmp(tabpanelId);
            var maintab = Ext.getCmp('mdata-client-main-panel');
//            if (tab.trim().length == 0) {
//                return;
//            }
            if(maintab.getSelectionModel().getCount() == 0){
            	Share.ShowMessage("I0011","一条客户基本信息");
            }
            if (maintab.getSelectionModel().getCount() > 1) {
                Share.ShowMessage("E0039","客户基本信息");
                return;
            }
            if (tab.getSelectionModel().getCount() == 0) {
                Share.ShowMessage("I0011","至少一条客户联系资料");
                return;
            }
//            if (tab.getSelectionModel().getCount() > 1) {
//                Ext.MessageBox.alert(Share.T('一次只能选择一条客户联系资料!'));
//                return;
//            }
            
//            var row = tab.getSelectionModel().getSelection()[0];
            var DATA = Ext.getCmp('mdata-client-main-panel').getSelectionModel().getSelection()[0];
            var STORE = Ext.getCmp('mdata-client-detail-panel').getStore();
            Ext.MessageBox.confirm(Share.T('提示'),Share.T('确定删除吗')+'？',function(btn){
            	if(btn == 'yes'){ 
            		var check = Share.checkFun();
        			if (check) {
//            		var id = Ext.getCmp('mdata-client-detail-panel').getSelectionModel().getSelection()[0].get('id');
            		if(Ext.getCmp('mdata-client-main-panel').getSelectionModel().getSelection()[0] == null |
            		   Ext.getCmp('mdata-client-main-panel').getSelectionModel().getSelection()[0] == ""){
            		        Share.ShowMessage("E0038");
            			return;
            		}
            		var cust_id = Ext.getCmp('mdata-client-main-panel').getSelectionModel().getSelection()[0].get('id');
            		var ids = '(';
            		var row = tab.getSelectionModel().getSelection();
            		for(i=0,len = row.length;i<len;i++){
            			var id = row[i].get('id');
                        ids += id;
                        if (i < len - 1) {
                            ids += ",";
                        }
            		}
            		ids += ')';
           		 Share.AjaxRequest({
                        url: ctx + "/deletemdataclientaddress",
                        params: {
//                        	cust_id: cust_id,
                            ids: ids
                        },
                        showMsg: false,
                        scope: this,
                        callback: function (json) {
                        	Share.ShowMessage("I0006","删除");
                        	STORE.load({
                    		    params: {mainId:cust_id},
                    		    callback: function(records, options, success){
                    		    	Records = records;
                    		    },
                    		    scope: STORE,
                    		    add: true
                    		});
                        	Ext.getCmp('mdata-client-detail-panel').getStore().reload();
                        	if(Ext.getCmp('mdata-client-detail-panel').getStore().getCount() == 1){
                    			Ext.getCmp('mdata-client-detail-panel').getStore().removeAll();
                    			Ext.getCmp('mdata-client-address-pag').movePrevious();
                    		}
                        //Ext.getCmp('mdata-client-main-panel').select(DATA);  
                        },
                        falseFun: function (json) { //失败后想做的个性化操作函数
                        	 Ext.MessageBox.alert(Share.T(json.msg));	
                        }
                    }); 
            	  }else {
	    				Share.ShowMessage("E0026");
	    				return;
	    			}
            	}
            });
		}
	},
	save: function (win) {  //保存(添加/修改)
   	 	var tabpanelId = 'tab-mdata-client';          
   	 	var tab = Ext.getCmp(tabpanelId);
        if (tab == undefined) {
            return;
        }
        
        var functionId = Ext.getCmp('mdata-functionId').value;
   	
        if (functionId == 1){  //基本信息添加-保存
        	var  form = Ext.getCmp('win-mdataclientaddpanel').down('form');
        	var basicForm = form.getForm();
            if (!basicForm.isValid()) {
            	return;
            }
            // 取得录入客户代码
        	var clientcode = Ext.getCmp('mdata-client-code-add').getValue();
        	// 当客户代码为空时自动生成客户代码
        	if (clientcode == '' || clientcode == null) {
        		Ext.Ajax.request({
        			url : ctx + "/getNewCustCode",
        			method : 'POST',
        			params : {},
        			async : false,
        			success : function(response) {
        				s = response.responseText;
        				json_f = Ext.JSON.decode(s);
        				clientcode = json_f.custCode;
        			}
        		});
        	}
        	var clientsupplier = Ext.getCmp('mdata-client-suport-add').getValue();
        	var clienttax = Ext.getCmp('mdata-client-tax-add').getValue();
        	var address = Ext.getCmp('mdata-client-address-add').getValue();
        	var bankaccount = Ext.getCmp('mdata-client-specialbank-add').getValue();
        	var clientbank = Ext.getCmp('mdata-client-bank-add').getValue();
        	var clienttel = Ext.getCmp('mdata-client-tel-add').getValue();
        	var invoiceType=Ext.getCmp('add-invtype').getValue();
        	var ck01 = Ext.getCmp('mdata-client-ck01-add').getValue();
        	var ck02 = Ext.getCmp('mdata-client-ck02-add').getValue();
        	var ck03 = Ext.getCmp('mdata-client-ck03-add').getValue();
        	var ck04 = Ext.getCmp('mdata-client-ck04-add').getValue();
        	var ck05 = Ext.getCmp('mdata-client-ck05-add').getValue();
        	var ck06 = Ext.getCmp('mdata-client-ck06-add').getValue();
        	var ck07 = Ext.getCmp('mdata-client-ck07-add').getValue();
        	var ck08 = Ext.getCmp('mdata-client-ck08-add').getValue();
        	var ck09 = Ext.getCmp('mdata-client-ck09-add').getValue();
        	var ck10 = Ext.getCmp('mdata-client-ck10-add').getValue();
        	if(clientsupplier.trim().length == 0){
        		Share.ShowMessage("I0010","客户名称");
        		return;
        	}
        	var ClientStore = Ext.getCmp('mdata-client-main-panel').getStore();
        	for(var i=0;i<ClientStore.getCount();i++){
        		if(clientcode == ClientStore.getAt(i).get('code')){
        			Ext.getCmp('mdata-client-code-add').markInvalid(Share.T('客户代码重复'));
        			return;
        		}
        	}
        	Share.AjaxRequest({
                url: ctx + "/addmdataclient",
                params: {
                	clientcode: clientcode,
                	clientsupplier: clientsupplier,
                	clienttax: clienttax,
                	address: address,
                	bankaccount: bankaccount,
                	clientbank: clientbank,
                	clienttel: clienttel,
                	invoiceType:invoiceType,
                	ck01: ck01,
                	ck02: ck02,
                	ck03: ck03,
                	ck04: ck04,
                	ck05: ck05,
                	ck06: ck06,
                	ck07: ck07,
                	ck08: ck08,
                	ck09: ck09,
                	ck10: ck10
                },
                showMsg: false,
                callback: function (json) {
//                    tab.getStore().reload();
//                	var ck10 = Ext.getCmp('mdata-client-ck10-add').getValue();
                	Share.ShowMessage("I0006","添加");
                	Ext.getCmp('mdata-client-main-panel').getStore().reload();
                    win.close();         	
                },
                falseFun: function (json) { //失败后想做的个性化操作函数
//                	var ck10 = Ext.getCmp('mdata-client-ck10-add').getValue();
//                	 Ext.MessageBox.alert(json.msg);	
                }
            });
        	Ext.getCmp('mdata-client-main-panel').getStore().reload();
        }else if (functionId == 2){  //基本信息修改-保存
        	var  form = Ext.getCmp('win-mdataclienteditpanel').down('form');
        	var basicForm = form.getForm();
            if (!basicForm.isValid()) {
            	return;
            }
        	var clientcode = Ext.getCmp('mdata-client-code-edit').getValue();
        	var clientsupplier = Ext.getCmp('mdata-client-suport-edit').getValue();
        	var clienttax = Ext.getCmp('mdata-client-tax-edit').getValue();
        	var address = Ext.getCmp('mdata-client-address-edit').getValue();
        	var bankaccount = Ext.getCmp('mdata-client-specialbank-edit').getValue();
        	var clientbank = Ext.getCmp('mdata-client-bank-edit').getValue();
        	var clienttel = Ext.getCmp('mdata-client-tel-edit').getValue();
        	var invoiceType=Ext.getCmp('edit-invtype').getValue();
        	var ck01 = Ext.getCmp('mdata-client-ck01-edit').getValue();
        	var ck02 = Ext.getCmp('mdata-client-ck02-edit').getValue();
        	var ck03 = Ext.getCmp('mdata-client-ck03-edit').getValue();
        	var ck04 = Ext.getCmp('mdata-client-ck04-edit').getValue();
        	var ck05 = Ext.getCmp('mdata-client-ck05-edit').getValue();
        	var ck06 = Ext.getCmp('mdata-client-ck06-edit').getValue();
        	var ck07 = Ext.getCmp('mdata-client-ck07-edit').getValue();
        	var ck08 = Ext.getCmp('mdata-client-ck08-edit').getValue();
        	var ck09 = Ext.getCmp('mdata-client-ck09-edit').getValue();
        	var ck10 = Ext.getCmp('mdata-client-ck10-edit').getValue();
        	var id = Ext.getCmp('hiddenID').getValue();
        	if(clientsupplier.trim().length == 0){
                        Share.ShowMessage("I0010","客户名称");
        		return;
        	}
        	Share.AjaxRequest({
                url: ctx + "/updatemdataclient",
                params: {
                	clientcode: clientcode,
                	clientsupplier: clientsupplier,
                	clienttax: clienttax,
                	address: address,
                	bankaccount: bankaccount,
                	clientbank: clientbank,
                	clienttel: clienttel,
                	invoiceType:invoiceType,
                	ck01: ck01,
                	ck02: ck02,
                	ck03: ck03,
                	ck04: ck04,
                	ck05: ck05,
                	ck06: ck06,
                	ck07: ck07,
                	ck08: ck08,
                	ck09: ck09,
                	ck10: ck10,
                	id  : id
                },
                showMsg: false,
                callback: function (json) {
//                    tab.getStore().reload();
                	Share.ShowMessage("I0006","修改");
                	Ext.getCmp('mdata-client-main-panel').getStore().reload();
            		Ext.getCmp('mdata-client-detail-panel').getStore().removeAll();
                },
                falseFun: function (json) { //失败后想做的个性化操作函数
//                	 Ext.MessageBox.alert(json.msg);	
                }
            });
        	win.close();  
        } else if(functionId == 3){  //联系方式添加-保存
        	var  form = Ext.getCmp('win-mdataclientaddressaddpanel').down('form');
        	var basicForm = form.getForm();
            if (!basicForm.isValid()) {
            	return;
            }
        	var DATA = Ext.getCmp('mdata-client-main-panel').getSelectionModel().getSelection()[0];
            var STORE = Ext.getCmp('mdata-client-detail-panel').getStore();
        	var recv_company = Ext.getCmp('mdata-client-recvcompany-add').getValue();
        	var recv_man = Ext.getCmp('mdata-client-recvman-add').getValue();
        	var recv_address = Ext.getCmp('mdata-client-recvaddress-add').getValue();
        	var recv_tel = Ext.getCmp('mdata-client-recvtel-add').getValue();
        	var city = Ext.getCmp('mdata-client-city-add').getValue();
        	var recv_remark = Ext.getCmp('mdata-client-recvremark-add').getValue();
        	var recv_email = Ext.getCmp('mdata-client-email-add').getValue();
        	var recv_phone = Ext.getCmp('mdata-client-phone-number-add').getValue();
        	var recv_ck01 = Ext.getCmp('mdata-client-recvck01-add').getValue();
        	var recv_ck02 = Ext.getCmp('mdata-client-recvck02-add').getValue();
        	var recv_ck03 = Ext.getCmp('mdata-client-recvck03-add').getValue();
        	var recv_ck04 = Ext.getCmp('mdata-client-recvck04-add').getValue();
        	var recv_ck05 = Ext.getCmp('mdata-client-recvck05-add').getValue();
        	var cust_id = Ext.getCmp('mdata-client-main-panel').getSelectionModel().getSelection()[0].get('id');
        	
        	if (!Ext.getCmp('mdata-client-recvman-add').isValid()) {
				return;
			}
        	
        	Share.AjaxRequest({
                url: ctx + "/addmdataclientaddress",
                params: {
                	recv_company: recv_company,
                	recv_man: recv_man,
                	recv_address: recv_address,
                	recv_tel: recv_tel,
                	city: city,
                	recv_remark: recv_remark,
                	recv_email: recv_email,
                	recv_phone: recv_phone,
                	recv_ck01: recv_ck01,
                	recv_ck02: recv_ck02,
                	recv_ck03: recv_ck03,
                	recv_ck04: recv_ck04,
                	recv_ck05: recv_ck05,
                	cust_id: cust_id
                },
                showMsg: false,
                callback: function (json) {
                	Share.ShowMessage("I0006","添加");
//                    tab.getStore().reload();
                	STORE.load({
            		    params: {mainId:cust_id},
            		    callback: function(records, options, success){
            		    	Records = records;
            		    },
            		    scope: STORE,
            		    add: true
            		});
                }
            });
        	win.close();
        } else if(functionId == 4){  //联系方式修改-保存
        	var  form = Ext.getCmp('win-mdataclientaddresseditpanel').down('form');
        	var basicForm = form.getForm();
            if (!basicForm.isValid()) {
            	return;
            }
        	var DATA = Ext.getCmp('mdata-client-main-panel').getSelectionModel().getSelection()[0];
            var STORE = Ext.getCmp('mdata-client-detail-panel').getStore();
        	var recv_company = Ext.getCmp('mdata-client-recvcompany-edit').getValue();
        	var recv_man = Ext.getCmp('mdata-client-recvman-edit').getValue();
        	var recv_address = Ext.getCmp('mdata-client-recvaddress-edit').getValue();
        	var recv_tel = Ext.getCmp('mdata-client-recvtel-edit').getValue();
        	var city = Ext.getCmp('mdata-client-city-edit').getValue();
        	var recv_remark = Ext.getCmp('mdata-client-recvremark-edit').getValue();
        	var recv_email = Ext.getCmp('mdata-client-email-edit').getValue();
        	var recv_phone = Ext.getCmp('mdata-client-phone-number-edit').getValue();
        	var recv_ck01 = Ext.getCmp('mdata-client-recvck01-edit').getValue();
        	var recv_ck02 = Ext.getCmp('mdata-client-recvck02-edit').getValue();
        	var recv_ck03 = Ext.getCmp('mdata-client-recvck03-edit').getValue();
        	var recv_ck04 = Ext.getCmp('mdata-client-recvck04-edit').getValue();
        	var recv_ck05 = Ext.getCmp('mdata-client-recvck05-edit').getValue();
        	var cust_id = Ext.getCmp('mdata-client-main-panel').getSelectionModel().getSelection()[0].get('id');
        	var id = Ext.getCmp('hiddenID').getValue();
        	
        	if (!Ext.getCmp('mdata-client-recvman-edit').isValid()) {
				return;
			}
        	
        	Share.AjaxRequest({
                url: ctx + "/updatemdataclientaddress",
                params: {
                	recv_company: recv_company,
                	recv_man: recv_man,
                	recv_address: recv_address,
                	recv_tel: recv_tel,
                	city: city,
                	recv_remark: recv_remark,
                	recv_email: recv_email,
                	recv_phone: recv_phone,
                	recv_ck01: recv_ck01,
                	recv_ck02: recv_ck02,
                	recv_ck03: recv_ck03,
                	recv_ck04: recv_ck04,
                	recv_ck05: recv_ck05,
                	cust_id: cust_id,
                	id: id
                },
                showMsg: false,
                callback: function (json) {
//                    tab.getStore().reload();
                	Share.ShowMessage("I0006","修改");
                	STORE.load({
            		    params: {mainId:cust_id},
            		    callback: function(records, options, success){
            		    	Records = records;
            		    },
            		    scope: STORE,
            		    add: true
            		});
                	Ext.getCmp('mdata-client-main-panel').select(DATA);       	
//                	Ext.getCmp('mdata-client-main-panel').getStore().reload();
                },
                falseFun: function (json) { //失败后想做的个性化操作函数
//                	 Ext.MessageBox.alert(json.msg);	
                }
            });
        	win.close();
        }
	},
    init: function(application) {
    	        this.control({
            "button": {
                click: this.onButtonClick
            }
        });
    }
    });